//引入 pinia插件
import { defineStore } from "pinia";
//引入vue文件
import { ref } from "vue";


//导出token
export const useTokenStore = defineStore("token", () => {

	//token信息
	const accessToken = ref('');

	//保存token信息
	const setAccessToken = (val : string) => {
		accessToken.value = val;
	}

	//清空token信息
	const clearAccessToken = () => {
		accessToken.value = "";
	}

	//返回数据
	return { accessToken, setAccessToken, clearAccessToken };

},
	//持久化
	{
		persist: {
			storage: {
				getItem(key) {
					return uni.getStorageSync(key);
				},
				setItem(key, value) {
					uni.setStorageSync(key, value);
				}
			}
		}
	}

)